<template>
    <view>
        <view>
            <form @submit="formSubmit" @reset="formReset">

                <view class="uni-form-item uni-column">
                    <view class="title">注册商家</view>
                    <input class="uni-input" v-model="seller.name" name="input" placeholder="请输入真实姓名" />
					<input class="uni-input" v-model="seller.ID" name="input" placeholder="请输入身份证号" />
					
                </view>
                <view class="uni-btn-v">
                    <button form-type="submit" style="background-color:  #F06C7A;">提交</button>
                    <button  type="default" form-type="reset">重置</button>
                </view>
            </form>
        </view>
    </view>
</template>
<script>
    export default {
        data() {
            return {
				uid:'',
				seller:{
					name:'',
					ID:'',
				}
            }
        },
		
        methods: {
            async formSubmit() {
				
				if(!(/^[\u4e00-\u9fa5]{2,4}$/.test(this.seller.name))){
					uni.showToast({title: '真实姓名有误',icon:"none"});
					return false; 
				}
				if(!(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(this.seller.ID))){
					uni.showToast({title: '身份证号码有误',icon:"none"});
					return false;
				}else{
					uni.showToast({
						title:'注册商家成功'
					})
				}
                const res = await this.$myRequest({
                			url: '/user/setSeller?username='+this.seller.name+'&identity='+this.seller.ID+'&id='+this.uid
                			})
                			console.log(res)
							
							this.seller.name=''
							this.seller.ID=''
                	
            },
            formReset: function(e) {
                console.log('清空数据')
            }
        },
		onLoad(option){
			console.log(option.uid)
			this.uid=option.uid
		}
    }
</script>

<style>
    .uni-form-item .title {
		text-align: center;
        padding: 20rpx 0;
		font-size: 30upx;
		color:  #F06C7A;
    }
	.uni-input-input, .uni-input-placeholder {
	    width: 60%;
	}
	.uni-form-item .uni-input{
		margin-top: 35upx;
		margin-left: 40%;
	}
	.uni-btn-v button{
		width: 30%;
	}
	.uni-btn-v{
		margin-left: 25%;
		margin-top: 35upx;
		display: flex;
		
	}
	uni-button {
		margin-left: 40upx;
	    position: relative;
	    display: block;
	    box-sizing: border-box;
	    font-size: 18px;
	    text-align: center;
	    text-decoration: none;
	    line-height: 2.55555556;
	    border-radius: 5px;
	    -webkit-tap-highlight-color: transparent;
	    overflow: hidden;
	    color: #000;
	    background-color: #f8f8f8;
	    cursor: pointer;
	}
	
</style>